package com.self.campussecondhandmarket.conf;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * Author: Vincent
 * <p> DateTime: 2024/8/5 21:15
 * <p> Description: 拦截器总配置
 * <p>
 **/
@Slf4j
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
	
	@Autowired
	JWTInterceptor jwtInterceptor;
	
	@Override
	protected void addInterceptors(InterceptorRegistry registry) {
		log.info("JWT拦截器正在启动");
		registry.addInterceptor(jwtInterceptor)
				.addPathPatterns("/api/**")
				.excludePathPatterns("/api/admin/login")
				.excludePathPatterns("/api/user/login")
				.excludePathPatterns("/api/user/register");
		log.info("JWT拦截器已启动");
	}
}
